package com.km.app.domain;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.io.Serializable;

@ApiModel("结构")
public class R<T> implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "逻辑代码")
    private Integer code = 0;
    @ApiModelProperty(value = "消息提示")
    private String message = "操作成功";
    @ApiModelProperty(value = "数据")
    private T data;

    public R() {
        super();
    }

    public R(Integer code, String message) {
        super();
        this.code = code;
        this.message = message;
    }

    public R(Integer code, String message, T data) {
        super();
        this.code = code;
        this.message = message;
        this.data = data;
    }


    public Integer getCode() {
        return code;
    }

    public R setCode(Integer code) {
        this.code = code;
        return this;
    }

    public String getMessage() {
        return message;
    }

    public R setMessage(String message) {
        this.message = message;
        return this;
    }

    public T getData() {
        return data;
    }

    public R setData(T data) {
        this.data = data;
        return this;
    }


    public R setCodeMessage(Integer code ,String message) {
        this.code = code;
        this.message = message;
        return this;
    }


    public R success() {
        this.code = 0;
        this.message = "Success";
        return this;
    }
    public R fail() {
        this.code = 100;
        this.message = "Fail";
        return this;
    }

}
